home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 September
/
PCWorld_2008-09_cd.bin
/
v cisle
/
sadanastroju
/
IE7proSetup_2.3.exe
/
IEProRs.dll
/
JS
/
EASY.JS
Wrap
Text File
|
2008-04-25
|
18KB
|
612 lines
function getObject(objName)
{
if(document.getElementById)
{
return eval('document.getElementById("' + objName + '")');
}
else if(document.layers)
{
return eval("document.layers['" + objName +"']");
}
else
{
return eval('document.all.' + objName);
}
}
function canDoAction(o,e) {
if(!o) { return false; }
switch (o.tagName) {
case "INPUT":
if (o.type=="button"||o.type=="submit") { return false; }
case "TEXTAREA":
case "SELECT":
return true;
default:
return false;
}
}
function getData(name, remplacements) {
var res = getObject("data_" + name).firstChild.data;
for (key in remplacements) {
if (remplacements.hasOwnProperty(key)) {
res = res.split("<\?" + key + "?\>").join(remplacements[key]);
}
}
if(name == "empty") {
res = res.replace("_HomeAddTip_",localeTable['home_addtip']);
}
return res;
}
function getTop(el) {
//var el = getObject(id);
var top = 0;
while (el.tagName=="P") {
el=el.parentNode;
}
while (el) {
top+=el.offsetTop;
el=el.offsetParent;
}
return top;
}
function getLeft(el) {
//var el = getObject(id);
var top = 0;
while (el.tagName=="P") {
el=el.parentNode;
}
while (el) {
top+=el.offsetLeft;
el=el.offsetParent;
}
return top;
}
/* <DATA> */
var pageThumbs = [];
var newTab = true;
var searchBar = true;
var pageCount = 24;
var cols = 3; var rows = 3;
for(var i=0; i<24; i++) {
pageThumbs[i] = new Array('', '', ''); //url, imgsrc, title
}
var easyHome = {};
var localeTable = {
home_title: 'Easy homepage',
home_addtip: 'Click to add a web page',
home_config: 'Config Easy Homepage',
home_newtab: 'Open in new Tab',
search_submit: 'Search',
input_tip: 'Please input URL:',
input_title: 'Select/input the easyhome URL',
input_ok: 'OK',
input_cancel: 'Cancel',
home_showsearch: 'Show search bar',
home_background: 'In background',
home_layout: 'Layout'
};
/* </DATA> */
function openConfig() {
getObject("confirm").style.display = (getObject("confirm").style.display == "" ) ? "none" : "";
getObject("dlg").style.display = "block";
getObject("confirm").focus();
for (var i=1; i<25; i++)
{
try { getObject("Image"+i).style.filter="gray"; } catch (ex) {}
}
}
function closeConfig() {
getObject("confirm").style.display="none";
getObject("dlg").style.display="none";
for (var i=1; i<25; i++) {
try { getObject("Image"+i).style.filter=""; } catch (ex) {}
}
}
function saveSettings() {
function sv(id) {
var sel = getObject(id);
return sel.options[sel.selectedIndex].text;
}
newTab=getObject("check1").checked;
searchBar=getObject("check2").checked;
BackgroundOpen=getObject("check4").checked;
rows=parseInt(sv("rowsCount"));
cols=parseInt(sv("colsCount"));
pageCount=(rows*cols);
PRO_setValue("EasyHome_newTab", String(newTab));
PRO_setValue("EasyHome_searchBar", String(searchBar));
PRO_setValue("EasyHome_BackgroundOpen", String(BackgroundOpen));
PRO_setValue("EasyHome_pageCount", String(pageCount));
PRO_setValue("EasyHome_rowsCount", String(rows));
PRO_setValue("EasyHome_colsCount", String(cols));
if (searchBar) {
getObject("searchBarPanel").style.display="";
} else {
getObject("searchBarPanel").style.display="none";
}
for (var i=1; i<25; i++) {
getObject("outbox-"+i).style.display=(i>pageCount?"none":"inline");
}
resizeContent();
}
function savePrefs() {
var s = '';
for(var i=0; i<pageCount; i++){
s += pageThumbs[i][0] + '\n';
}
easyHome.homePrefs = s;
}
var canOpen = true; var buttonP=false;
function openBox(index,e) {
if (getObject("menu_nav").style.display=="") {
return true;
}
e = window.event;
e.returnValue = false;
e.cancelBubble = true;
if (buttonP) {
buttonP=false;
return false;
}
var url = pageThumbs[index-1][0];
if(url != '') {
if (!canOpen) { return true; }
openURL(url);
canOpen = false;
setTimeout("canOpen=true", 250);
} else {
editBox(index)
}
}
function openURL(url) {
function inNewTab() {
if(newTab) { return true; }
if (window.event) {
return ((window.event.button==3) || (window.event.button==4));
} else {
return false;
}
}
if (BackgroundOpen){
PRO_openInTab(url,inNewTab()?2:0);
} else {
PRO_openInTab(url,inNewTab()?1:0);
}
}
function closeBox(index, e) {
var tid = getObject('Title' + index);
if(tid){
tid.innerHTML = "";
}
getObject("imgshow"+index).innerHTML=getData("empty", {index:index});
getObject("box-bottons-inner"+index).innerHTML="";
pageThumbs[index-1][0] = "";
savePrefs();
}
var menuIndex=1;
function menuBox(index, e) {
menuIndex=index;
var left = (e.offsetX+getLeft(e.srcElement)) + "px";
var top = (e.offsetY+getTop(e.srcElement)) + "px";
var style = getObject("menu_nav").style;
style.top = top;
style.left = left;
style.display = "";
var updateTime = getUpdateTime(index);
getObject("menu-1").style.background="";
getObject("menu15000").style.background="";
getObject("menu30000").style.background="";
getObject("menu60000").style.background="";
getObject("menu300000").style.background="";
getObject("menu900000").style.background="";
getObject("menu1800000").style.background="";
getObject("menu3600000").style.background="";
getObject("menu86400000").style.background="";
getObject("menu"+updateTime).style.background="#daf0ff";
}
function closeMenu() {
var style = getObject("menu_nav").style;
style.display = "none";
}
function refreshBox(index) {
var url = pageThumbs[index-1][0];
if(url != '') {
setLastUpdate(index, (new Date()).getTime());
var iid = getObject('imgshow' + index).getElementsByTagName("img")[0];
easyHome.captureImage(index, url, true, 30);
if(iid){
getObject('box-bottons-inner' + index).innerHTML="<img src=img/loading2.gif border=0>";
}
}
}
function refreshBoxAll() {
for (var i=1; i<pageCount+1; i++) {
try{
refreshBox(i);
} catch(ex) {}
}
}
function editBox(index) {
var url = pageThumbs[index-1][0];
var tTable = {
itab: localeTable,
ifav: easyHome.getFavorites(),
iurl: url,
ihis: easyHome.getTabHistory()
};
//pop input dialog
url = window.location.href;
url = url.substr(0, url.lastIndexOf('/')+1);
url += "inputurl.html";
url = PRO_showModalDialog(url, tTable, 'dialogWidth:500px; dialogHeight:404px; scroll: no; status: no;');
if(url == undefined || url == '') return;
setUpdateTime(index, "-1");
var el = getObject("imgshow"+index);
try {
el.getElementsByTagName("img")[0].src="img/loading.gif";
el.getElementsByTagName("a")[0].href=url;
} catch (ex) {
el.innerHTML = getData("image", {"index":index})
el.getElementsByTagName("img")[0].src="img/loading.gif";
el.getElementsByTagName("a")[0].href=url;
}
getObject("box-bottons-inner"+index).innerHTML= getData("buttons", {"index":index});
pageThumbs[index-1][0] = url;
refreshBox(index);
//save prefs
savePrefs();
}
sfHover = function() {
var sfEls = getObject("nav").getElementsByTagName("LI");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" sfhover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
}
}
}
window.attachEvent("onload", sfHover);
document.attachEvent("onclick", closeMenu);
/* Handles */
function onCaptureImage(i, url, imgurl, title)
{
pageThumbs[i-1][0] = url;
pageThumbs[i-1][1] = imgurl;
pageThumbs[i-1][2] = title;
//set title
var tid = getObject('Title' + i);
if(tid){
tid.outerHTML = "<span id='Title"+i+"' style='float:left;width:0px;display:block'>"+title+"</span>";
}
//set img
var el = getObject("imgshow"+i);
try {
el.getElementsByTagName("img")[0].src=imgurl;
} catch (ex) {
el.innerHTML = getData("image", {"index":i})
el.getElementsByTagName("img")[0].src=imgurl;
el.getElementsByTagName("a")[0].href=url;
}
getObject("box-bottons-inner"+i).innerHTML= getData("buttons", {"index":i});
}
function resizeContent()
{
for (var i=1; i<pageCount+1; i++) {
try{
getObject("imgshow"+i).style.height=getH()+'px';
getObject("imgshow"+i).style.width=getW()+'px';
} catch(ex) {}
}
}
var startSwap=0;
function swap(toIndex) {
getObject("img_souris").style.display="none";
if (startSwap != 0) {
var startIndex = startSwap; startSwap = 0;
if (toIndex == startIndex) { return true; }
var Info1 = pageThumbs[toIndex-1].join("\n").split("\n");
var Info2 = pageThumbs[startIndex-1].join("\n").split("\n");
closeBox(startIndex); closeBox(toIndex);
setTimeout(function() {
if (Info1[0]!="") {
onCaptureImage(startIndex, Info1[0], Info1[1], Info1[2]);
}
if (Info2[0]!="") {
onCaptureImage(toIndex, Info2[0], Info2[1], Info2[2]);
}
savePrefs();
}, 100)
}
return true;
}
function mouse()
{
try {
if(getObject)
{
getObject("img_souris").style.left = event.clientX+10 + document.body.scrollLeft;
getObject("img_souris").style.top = event.clientY+10 + document.body.scrollTop;
}
else if(document.all)
{
document.all["img_souris"].style.left = event.clientX+10 + document.body.scrollLeft;
document.all["img_souris"].style.top = event.clientY+10 + document.body.scrollTop;
}} catch(ex) {}
}
document.onmousemove = mouse;
window.onload = function loadContent()
{
if(navigator.userLanguage && navigator.userLanguage == "zh-cn") {
var searchForm = getObject("search_form");
searchForm.action = "http://www.google.cn/search";
var text = "<input type=\"hidden\" name=\"hl\" value=\"zh-CN\" /><input type=\"hidden\" name=\"client\" value=\"aff-ie7pro\" />";
searchForm.insertAdjacentHTML("beforeEnd", text);
getObject("search_logo").src = "img/google.gif";
}
//startList();
easyHome = PRO_easyHome();
for (var name in localeTable){
var str = easyHome.getString(name);
if(str != '') localeTable[name] = str;
}
var i;
document.title = localeTable['home_title'];
try {
getObject('search_submit').value = localeTable['search_submit'];
getObject('home_config').innerHTML = localeTable['home_config'];
getObject('home_newtab').innerHTML = localeTable['home_newtab'];
getObject('home_showsearch').innerHTML = localeTable['home_showsearch'];
getObject('home_background').innerHTML = localeTable['home_background'];
getObject('input_submit').value = localeTable['input_ok'];
getObject('home_layout').innerHTML = localeTable['home_layout'];
} catch(ex) {}
for(i=1; i < pageCount+1; i++){
var addtipobj = getObject('home_addtip'+i);
if(addtipobj) {
addtipobj.innerHTML = localeTable['home_addtip'];
}
}
var s = easyHome.homePrefs;
var urls = s.split('\n');
for(i=0; i < pageCount; i++){
if(i<urls.length) pageThumbs[i][0] = urls[i];
else pageThumbs[i][0] = '';
}
easyHome.oncapturefinish = onCaptureImage;
for(i=1; i<pageCount+1; i++){
if(pageThumbs[i-1][0] != '') {
var el = getObject("imgshow"+i);
if (el) {
el.innerHTML = getData("image", {"index":i})
el.getElementsByTagName("a")[0].href=pageThumbs[i-1][0];
var iid = getObject('Image' + i);
if(iid){
iid.src = "img/loading.gif";
}
if (mustUpdate(i)) {
refreshBox(i);
} else {
easyHome.captureImage(i, pageThumbs[i-1][0], false, 30);
}
}
getObject("box-bottons-inner"+i).innerHTML= getData("buttons", {"index":i});
}
}
try {
newTab=(PRO_getValue("EasyHome_newTab", "true")=="true");
searchBar=(PRO_getValue("EasyHome_searchBar", "true")=="true");
BackgroundOpen=(PRO_getValue("EasyHome_BackgroundOpen", "true")=="true");
pageCount = parseInt(PRO_getValue("EasyHome_pageCount","9"));
rows = parseInt(PRO_getValue("EasyHome_rowsCount","3"));
cols = parseInt(PRO_getValue("EasyHome_colsCount","3"));
} catch (ex) {}
getObject("check1").checked=newTab;
getObject("check2").checked=searchBar;
getObject("check4").checked=BackgroundOpen;
function ssv(id,v) {
var sel = getObject(id);
for (var i=0; i<sel.options.length; i++) {
if (sel.options[i].text==v) {
sel.selectedIndex=i;
return true;
}
}
return false;
}
ssv("rowsCount", String(rows));
ssv("colsCount", String(cols));
saveSettings();
resizeContent();
window.attachEvent('onresize', resizeContent);
}
function getH() {
var h = document.documentElement.offsetHeight;
if (document.compatMode=="BackCompat") {
h = document.body.offsetHeight;
}
if (rows==1) {
h = parseInt((h-(275*(rows/3)))/rows) - 70
} else if (rows==2) {
h = parseInt((h-(275*(rows/3)))/rows) - 25
} else if (rows==3) {
h = parseInt((h-(275*(rows/3)))/rows) - 7
} else if (rows==4) {
h = parseInt((h-(275*(rows/3)))/rows)
} else if (rows==5) {
h = parseInt((h-(275*(rows/3)))/rows)
} else if (rows==6) {
h = parseInt((h-(275*(rows/3)))/rows)
}
if (!searchBar) {
h += parseInt(50/rows);
}
return (h);
// return (((h-295))/4)+"px";
}
function getW() {
var w = document.documentElement.offsetWidth;
if (document.compatMode=="BackCompat") {
w = document.body.offsetWidth;
}
if (cols==1) {
w = parseInt((w-(275*(cols/3)))/cols) - 70
} else if (cols==2) {
w = parseInt((w-(275*(cols/3)))/cols) - 25
} else if (cols==3) {
w = parseInt((w-(275*(cols/3)))/cols) - 7
} else if (cols==4) {
w = parseInt((w-(275*(cols/3)))/cols) + 14
} else if (cols==5) {
w = parseInt((w-(275*(cols/3)))/cols) + 17
} else if (cols==6) {
w = parseInt((w-(275*(cols/3)))/cols) + 20
}
if (!searchBar) {
w += parseInt(50/cols);
}
return (w);
}
//setInterval(function() { try { window.recalc(); } catch (ex) {} }, 100);
document.attachEvent("onmousedown", function onMouseDown(e) {
var midb = false;
var e=window.event;
if (window.event) {
midb = ((window.event.button==3) || (window.event.button==4));
} else {
midb = (e.which==2);
}
if (midb) {
e.returnValue = false;
e.cancelBubble = true;
for (var i=1; i<pageCount+1; i++) {
if (getObject("ibox"+i).focus()) {
openBox(i, e);
return false;
}
}
return false;
}
return true;
});
var dlgOpacity=10;
function setDlgOpacity() {
try {
if (getObject("dlg").style.display=="none") {
dlgOpacity=10;
} else if (dlgOpacity<45) {
dlgOpacity++;
}
getObject("dlg").style.filter="alpha(opacity="+dlgOpacity+")";
} catch (ex) {}
}
//setInterval(setDlgOpacity, 50);
function setUpdateTime(index, time) {
PRO_setValue("EasyHome_"+index+"_time",time)
}
function getUpdateTime(index) {
return parseInt(PRO_getValue("EasyHome_" + index + "_time","-1"));
}
function getLastUpdate(index) {
return parseInt(PRO_getValue("EasyHome_" + index + "_update","0"));
}
function setLastUpdate(index, time) {
PRO_setValue("EasyHome_" + index + "_update",time);
}
function mustUpdate(index) {
var lastTime = getLastUpdate(index);
var updateTime = getUpdateTime(index);
if (updateTime==(-1)) { return false; }
if ((new Date()).getTime() - lastTime > updateTime) {
return true;
}
return false;
}
setInterval(function() {
for (var index=1; index<pageCount+1; index++) {
if (mustUpdate(index)) {
refreshBox(index);
}
}
}, 6000);
document.pressedText=""; document.onKeyPressTimer=0;
document.attachEvent("onkeypress", function onKeyPress() {
if(event.srcElement.tagName == "INPUT") return;
var chr = String.fromCharCode(event.keyCode);
clearTimeout(document.onKeyPressTimer);
if ((/[0-9]/).test(chr)) {
document.pressedText+=chr;
document.onKeyPressTimer=setTimeout(function() {
var index = (parseInt(document.pressedText));
var url;
try {url = pageThumbs[index-1][0];} catch(ex){}
if(url!="") { openURL(url); }
document.pressedText="";
}, 333)
} else {
document.pressedText="";
}
})